read_arg=""
if [ -n "$BASH_VERSION" ]; then
    read_arg='-a'
elif [ -n "$ZSH_VERSION" ]; then
    read_arg='-rA'
else
    echo "Unknown shell, exiting."
    exit 1
fi

# zsh 数组下标从 1 开始
function _jalias_tool_get_slice_idx() {
    old_idx="$1"
    if [ -n "$ZSH_VERSION" ]; then
        echo $(("$old_idx" + 1))
    else
        echo "$old_idx"
    fi
}

function shell_rc_file() {
    case $SHELL in
    *bash*)
        # sh_type="bash"
        echo "$HOME/.bashrc"
        ;;
    *zsh*)
        # sh_type="zsh"
        echo "$HOME/.zshrc"
        ;;
    *)
        echo "Unsupported shell types"
        ;;
    esac
}

# function _jalias_keys_test() {
#     echo "a b c d e f g"
# }
# global_compreply=()

# IFS=" " read "$read_arg" global_compreply <<<"$(_jalias_keys_test)"

# echo "${global_compreply[@]}"
